<?php
App::uses('AppModel', 'Model');
/**
 * Office Model
 *
 * @property officeInteraction $officeInteraction
 */
class Office extends AppModel {

/**
 * Use table
 *
 * @var mixed False or table name
 */
	public $useTable = 'offices';

/**
 * Primary key field
 *
 * @var string
 */
	public $primaryKey = 'o_id';
	public $displayField = 'o_name';

	//The Associations below have been created with all possible keys, those that are not needed can be removed

	public $validate = array(
			'o_name' => array(
				'alphaNumeric' => array(
					'rule'     => array('custom', '/^[a-z0-9 ]*$/i') ,
					'message'  => 'Letters and Numbers only'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Office name can not be empty'
				)
			),
			'o_address' => array(
				'alphaNumeric' => array(
					'rule'     => array('custom', '/^[a-z0-9 ]*$/i') ,
					'message'  => 'Letters and Numbers only'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Address can not be empty'
				)
			),
			'o_postcode' => array(
				'postcode' => array(
					'rule' => array('between', 4, 4),
					'message' => 'Postcode Must be 4 numbers long'
				),
				'number' => array(
					'rule' => 'numeric',
					'message' => 'Please enter numbers only'
				),
				
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Postcode can not be empty'
				)
			),
			'o_phone' => array(
				'number' => array(
					'rule' => 'numeric',
					'message' => 'Please enter numbers only'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Phone number can not be empty'
				),
				'length' => array( 
					'rule' => array('between', 10, 10),
					'message' => 'Phone Number Must be 10 characters long' 
				)
			),
			'o_email' => array(
				'email' => array(
				'rule'    => array('email', true),
				'message' => 'Please supply a valid email address.'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Email can not be empty'
				)
			)
		);
	
/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'Interaction' => array(
			'className' => 'Interaction',
			'foreignKey' => 'o_id'
		)
	);


}
